def get_cn_id_suffix(xstr):
    xprompt = 'The parameter must be a valid CN ID 17 characters prefix'
    if type(xstr) != str:
        raise ValueError(xprompt)
    if len(xstr) < 17:
        raise ValueError(xprompt)
    # 余数只可能有0 1 2 3 4 5 6 7 8 9 10这11个数字。其分别对应的最后一位身份证的号码为1 0 X 9 8 7 6 5 4 3 2
    map = '10X98765432';
    Ls = []
    fs = []
    arr = []
    sum = 0
    for i in range(17):
        o = i + 1
        try:
            L = int(xstr[i])
        except ValueError:
            raise ValueError(xprompt)
        Ls.append(L)
        f = 1
        f <<= (18 - o)
        f %= 11
        fs.append(f)
        r = f * L
        arr.append(r)
        sum += r
        fr = sum % 11
        suffix = map[fr]
        # print(Ls, fs, arr, sum, fr, map, suffix)
    return suffix


if '__main__' == __name__:
    print(get_cn_id_suffix('37292219830130001'))
